from ECShop_no9_自动化测试.common.base import create_browser,Base,base_sql_add
from ECShop_no9_自动化测试.common.base import create_browser_op
import time
class Page_user_center_update_addr(Base):
    #前置条件的标签
    url='http://localhost:8080/ecshop/user.php'
    cart_click=('xpath',("//div[@class='cart']/a"))
    fuz_content = ('link text', '服装')
    add_pag = ('xpath', "//img[@class='goodsimg']")
    add_cart = ('xpath', "//img[@src='themes/default/images/buybtn1.png']")  # 添加包到购物车
    buy = ('xpath', ("//td[@align='right']/a/img"))  # 结算

    get_addr=('xpath',"//div[@class='userCenterBox']/div/a[4]/img")#收货地址标签

    sure_update_addr=('xpath',"//td[@colspan='3']/input") #点击确认修改按钮
    input_name_click=('xpath',"//td[@align='left']/input")  #姓名输入框
    input_name_click2=('xpath',"input[@id='consignee_0' and @class='inputBg']")
    city_click=('xpath',"//select[@name=city]") #城市



    # 打开网页
    def page_shop_cart_web(self):
        self.base_open_web(self.url)
    #点击收货地址
    def page_user_center_get_addr(self):
        self.base_click(self.get_addr)
    #点击修改地址
    def page_user_center_sure_update_addr_click(self):
        self.base_click(self.sure_update_addr)
    #点击姓名输入框
    def page_user_center_inupt_name_click(self):
        self.base_click(self.input_name_click)
    #清空
    def page_user_center_clear_input_name(self):
        self.base_clear(self.input_name_click)
    #输入新的姓名
    def page_user_center_input_new_name(self,your_content):
        self.base_input_content(self.input_name_click,your_content)
    #点击确认修改
    def page_user_sure_update_click(self):
        self.base_click(self.sure_update_addr)
    # #修改城市
    # def page_user_addr_update_city(self, your_content):
    #     self.base_select(self.city_click ,your_content)
    # #获取城市的文本
    # def page_get_city_text_is_success(self):
    #     result=self.base_get_text(self.city_click)
    #     return result
    #获取姓名的文本
    # def page_get_name_text_is_success(self):
    #     result=self.base_get_text(self.input_name_click2)
    #     return result




    #关闭
    def page_user_center_quit(self):
        self.base_quit()


if __name__ == '__main__':
    p1=Page_user_center_update_addr(create_browser_op(r'C:\Users\86183\AppData\Local\Google\Chrome\User Data'))
    p1.page_shop_cart_web()
    p1.page_user_center_get_addr()#点击收货地址
    p1.page_user_center_sure_update_addr_click()#点击确认修改
    time.sleep(7)
    p1.page_user_center_inupt_name_click() #点击姓名输入框
    time.sleep(6)
    p1.page_user_center_clear_input_name()#清空输入框
    time.sleep(5)
    p1.page_user_center_input_new_name('李四') #输入新的名字
    time.sleep(3)
    p1.page_user_sure_update_click() #点击确认修改
    # time.sleep(5)
    # print(p1.page_get_name_text_is_success())
    time.sleep(6)
    print(base_sql_add("SELECT * FROM `ecs_user_address` where address='光华公园'", 'consignee'))
    # p1.page_user_addr_update_city('成都市')
    # print(p1.page_get_city_text_is_success())
    # p1.page_user_center_quit()





